﻿<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@page import="com.aiflow.Action.DictionaryAction"%>
<%@page import="com.aiflow.Action.DepartmentAction"%>
<%@ page import="com.aiflow.bean.User"%>
<html>
<head>
	<%
		String personConfId = request.getParameter("personConf");
		User use = (User)session.getAttribute("user");
	%>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
	var alarmTypes = [];
	var editPersonConfFormPanel = null;
	var sexStore  ;
		$(document).ready(function(){
			// 工具栏
		    var toolbar = new Ext.Toolbar({
		    	renderTo: 'editPersonConfToolBarDiv',
		    	items: [
				    new Ext.Button({
					    id: 'editPersonConf-save-button',
						text: '保存',
						iconCls: 'tick'
					}),
					new Ext.Button({
					    id: 'editPersonConf-cancel-button',
						text: '取消',
						iconCls: 'cancel'
					})
				]
			});
               
               // 告警类型数据源
               var alarmStore = new Ext.data.ArrayStore({  
	            fields : ['alarm_id', 'alarm_name'],  
	            data : <%=DictionaryAction.getDictionaryCombo("748")%>,
	            sortInfo: {field: "alarm_id", direction: "ASC"}
	        });
	        
	         // 区域  数据源  getDepartmentCombo
	         var regionStore = new Ext.data.ArrayStore({  
	            fields : ['region_id', 'region_name'],  
	            data : <%=DepartmentAction.getDepartmentCombods(use.getDept_id())%>,
	            sortInfo: {field: "region_id", direction: "ASC"}
	        });
	        
	           var specialtyStore = new Ext.data.ArrayStore({  
	            fields : ['specialty_id', 'specialty_name'],  
	            data : <%=DictionaryAction.getDictionaryCombo("98")%>,
	            sortInfo: {field: "specialty_id", direction: "ASC"}
	        });
			 

	            var  editPersonConfFormPanel = new Ext.FormPanel({
				renderTo: 'editPersonConfFormDiv',
		        labelWidth: 70,
		        border: false,
		        bodyStyle: 'background-color:transparent;',
		         items: [{
		            layout:'form',
		            border: false,
		            bodyStyle: 'padding:5px;background-color:transparent;',
		            items:[
		                    {//  传报编号
			               xtype:'hidden',
			                name: 'id',
			                fieldLabel: '编号',
			                anchor:'98%',
			                allowBlank:false,
			                maxLength: 20
		                   },{//  传报编号
			               xtype:'textfield',
			                name: 'user_name',
			                fieldLabel: '姓名',
			                anchor:'98%',
			                allowBlank:false,
			                maxLength: 20
		                   },{//    手机号
			                xtype:'textfield',
			                name: 'telep',
			                fieldLabel: '手机号码',
			                anchor:'98%',
			            //   regex: /^1[\d]{10}$/,
                            regexText: '手机号码必须1开头,后面跟10位数字！',
                            allowBlank:false,
			                maxLength: 20
			           },{  
			                xtype:'combo',
			                hiddenName: 'superviseTarget',
			                fieldLabel: '传报对象',
			                store: alarmStore,
			                mode : 'local',
			                triggerAction: "all",
			                valueField: 'alarm_id',
			                displayField: 'alarm_name',
			                allowBlank:false,
			                editable: false,
			                width: 230,
			                anchor:'98%'
			           },{  
			                xtype:'combo',
			                hiddenName: 'region',
			                fieldLabel: '所属省市',
			                store: regionStore,
			                mode : 'local',
			                triggerAction: "all",
			                valueField: 'region_id',
			                displayField: 'region_name',
			                allowBlank:false,
			                editable: false,
			                width: 230,
			                anchor:'98%'
			           },{  
			                xtype:'combo',
			                hiddenName: 'specialty',
			                fieldLabel: '专业',
			                store: specialtyStore,
			                mode : 'local',
			                triggerAction: "all",
			                valueField: 'specialty_id',
			                displayField: 'specialty_name',
			                allowBlank:false,
			                editable: false,
			                width: 230,
			                anchor:'98%'
			           },{//   描叙
			                xtype:'textarea',
			                id: 'describe',
			                name: 'describe',
			                fieldLabel:'描叙',
			                width: 230,
			                anchor:'98%'
			              
		                },{// 操作类型
				           id:'buttonType',
			               xtype:'hidden',
			               name: 'type',
			               value: 'cancel'
			           }]
		                 
		        }]
		    });

		    // 发送请求-form初期化
			Anynote.ajaxRequest({
				baseParams: {personConfId:<%=personConfId%>},
				action: '${pageContext.request.contextPath}/getPersonConfig.action',
				callback: function(jsonResult){
		     	     editPersonConfFormPanel.getForm().setValues(jsonResult);
				}
			});

		    // 保存按钮
		    $("#editPersonConf-save-button").click(function(){
			    var form = editPersonConfFormPanel.getForm();
			    if(form.isValid()){
			    	// 发送请求
					Anynote.ajaxRequest({
						baseParams: form.getValues(),
						action: '${pageContext.request.contextPath}/updatePersonConfig.action?',
						callback: function(jsonResult){
						     personConfListGrid.getStore().reload();
						     editPersonConfWindow.close();
						},
						showWaiting: true,
						failureMsg: '保存失败.'
					});
				}
			});
			
		 	// 取消按钮
		    $("#editPersonConf-cancel-button").click(function(){
		    	Ext.getCmp("buttonType").setValue("cancel");
		    	editPersonConfWindow.close();
			});
		});
	</script>
</head>
<body> 
<div id="editPersonConfDiv" style="width:100%;height:100%;">
	<div id="editPersonConfToolBarDiv"></div>
	<div id="editPersonConfFormDiv"></div>
</div>


</body>
</html>